import java.util.Random;

/**
 * Created by dllo on 18/4/2.
 */


//random的nextInt(int n)方法可以生成一个介于0(包含)到n(不包含)之间的整数
//        nextInt(101)生成的就是0~100之间的随机数，包含0和100
public class NO2 {
    public static void main(String[] args) {
     /*   Random random = new Random();
        int[] arr = new int[20];
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(20);
            if (arr[i] > 10) {
                count++;
            }
        }


        System.out.println(count);
        System.out.println("===========================================");
        int[] newArr = new int[count];
        int j = 0;
        for (int i = 0; i < arr.length; i++) {

            if (arr[i] > 10) {
                newArr[j] = arr[i];
                System.out.println(newArr[j]);
                j++;

            }

        }*/

        Random random = new Random();

        int[] arr = new int[20];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(20);
        }

        //输出数组
        System.out.print("[");  // 不带换行
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]);
            if (i != arr.length - 1) {
                //只要不是最后一个数字,就加上 ,
                System.out.print(", ");


            }
        }
        System.out.println("]");  //带换行

        int length = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > 10) {
                length++;  // 每发现一个符合条件的数,长度就加1
            }
        }
        System.out.println(length);
        int[] newArr = new int[length];

        int index = 0;  //新数组下标
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > 10) {
                newArr[index++] = arr[i];

            }
        }

        System.out.print("[");
        for (int i = 0; i < newArr.length; i++) {

            System.out.print(newArr[i]);
            if (i != newArr.length - 1) {
                System.out.print(", ");
            }
        }
        System.out.println("]");


    }
}
